<table >
    <!--<form method="post" >-->
    <tr >
        <!--đây là form tìm kiếm-->
        <td >
            <!--            <div class="tim_kiem">
                            <input type="text" />
                        </div>-->
            <div class="tim_kiem">
                <form method="post">
                    <input type="text" name="Tsearch" />
                    <!--            </div>
                                <div class="tim_kiem">-->
                    <input type="submit" value="click" name="Ssearch" />
                </form>
            </div>
        </td >

    <!--đây là form rỗng dùng để tách nó ra-->
    <td style="width: 300px;"></td>

    <!--đây là form login-->
    <td >
        <?php
        if (isset($_SESSION['user'])) {
            if ($_SESSION['quyen'] == 1) {
                echo 'xin chào quản trị viên : <a href="index.php?content=info_canhan" >' . $_SESSION['user'] . '</a>';
                ?>
                <a href="#" onclick="location.href = './php/info-canhan/thoat.php'">thoát</a>
                <?php
            } else {
                echo 'xin chào khách hàng : <a href="index.php?content=info_canhan" >' . $_SESSION['user'] . '</a>';
                ?>
                <a href="#" onclick="location.href = './php/info-canhan/thoat.php'">thoát</a>
                <?php
            }
        } else {
            ?>
            <table class="tung" cellspacing="0">
                <tr >
                    <td colspan="3" style="height: 100%;" class="khung">
                        <div id="form_login" >
                            <form method="post" >
                                username
                                <input type="text" name="username" />
                                password
                                <input type="password" name="password" />
                                <input type="submit" value="gửi" name="smit"/>
                                <div > <a href="index.php?content=dang_ky" >đăng ký </a></div>
                            </form>
                        </div>
                    </td>
                </tr>
            </table> 
            <?php
        }
        ?>
    </td>
</tr>
<!--</form >-->  
<?php
if (isset($_POST['username'])) {
    $result = mysql_query("select * from nguoi_dung where USERNAME='" . $_POST['username'] . "'");
    $row = mysql_num_rows($result);
    if (mysql_num_rows($result) >= 1) {
        $row = mysql_fetch_array($result);
        $_SESSION['user'] = $row['USERNAME'];
        ?>
        <script > window.location.href = "index.php";</script>
        <?php
        $_SESSION['quyen'] = $row['Quyen'];
    }
}
?> 
</table>

